﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _2023._5._8超市收银系统
{
    /// <summary>
    /// 买M元送N元
    /// </summary>
    class DiscountMN:DisountFather
    {
        int _M;
        int _N;

        public DiscountMN(int m,int n)
        {
            _M = m;
            _N = n;
        }

        public int N { get => _N; set => _N = value; }
        public int M { get => _M; set => _M = value; }

        public override double LastMoney(double money)
        {
            if (money > M)
            {
                money = money - (int)(money / M) * N;
            }
            return money;
        }
    }
}
